qx.Class.define("bip.services.QuestionService",
{
  extend : qx.core.Object,
  
  events :
  {
    /**
     * Data event fired after the model has been created. The data will be the
     * created model.
     */
    "loaded" : "qx.event.type.Data",

    /**
     * Fired when an error (aborted, timeout or failed) occurred
     * during the load. If you want more details, use the {@link #changeState}
     * event.
     */
    "error" : "qx.event.type.Event"
  },
  
  construct : function(url, delegate)
  {
    this.base(arguments);
    this.__store = new bip.rpc.Json(null, null);
    this.__store.bind("model", this, "question");
    this.__store.addListener("error",function(evt) {
    	this.fireDataEvent("error",evt.getData());
    },this);
    this.__store.addListener("loaded",function(evt) {
    	this.fireDataEvent("loaded",evt.getData());
    },this);
    
  },
  
  properties : {
    question : {
      nullable: true,
      event: "changeQuestion"
    }
  },
  

  members :
  {
    __store : null,
    
    postQuestion : function(topic) {
    	this.__store.setUrl(null);
    	this.__store.setModel(this.getQuestion());
    	this.__store.setUrl("questions/createQuestion");
    }
  }
});